//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;
using OpenLS.Drawing;
using OpenLS.Drawing.UI;
using OpenLS.Drawing.UI.Internals;

namespace OpenLS.Chart.UI
{
    class StrokeConverter: IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            LineProperties stroke = StrictConverter.Convert<LineProperties>(values[0]);
            ColorScheme scheme = values[1] as ColorScheme;
            if (scheme == null)
                scheme = BuiltInThemes.DefaultTheme.ColorScheme;
            if (stroke != null && stroke.LineFillProperties != null)
                return LineFillPropertiesToBrushConverter.GetBrush(stroke.LineFillProperties, scheme);
            FillPattern pattern = new AccentFillPattern();
            if (values.Length > 2)
                return ColorBaseToBrushConverter.ColorBaseToBrush(pattern.GetColor((int)values[2]), scheme);
            return ColorBaseToBrushConverter.ColorBaseToBrush(scheme.Dark1, scheme);

        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
